package com.soc.web.client.api;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.ui.HTMLPanel;

public class FancyboxUtils {
	public static String getUniqueId() {
		return HTMLPanel.createUniqueId();
	}
	
	public static int getLength(JSONArray object) {
		if(object.isArray() != null) {
			return object.size();
		}		
		return -1;
	}
	
	public static native int getArrayLengthFromJavascriptObject(JSONArray object) /*-{
		var len = object.length;
		return (len == undefined) ? -1 :  len;		
	}-*/;
	
	public static JSONValue convertJSO(JavaScriptObject object) {
		return new JSONObject(object);
	}
}
